<template>
	<view class="top">
		<view class="scr" @click="enter">商品搜索
			<image class="imagesrc" src="../../static/scrlogo.png" mode=""></image>
		</view>
		<view>
			<scroll-view class="scroll-view_H" @scroll="scroll">
				<view class="scroll-view-item_H" v-for="(tab,index) in tabBars" :key="index" :id="tab.id"
					:class="navIndex==index?'activite':''" @click="checkIndex(index)">{{tab.cat_name}}</view>
			</scroll-view>
			<!-- 内容切换 -->
			<view class="content" v-if="navIndex==0">
				<view class="navindexzero" v-for="data,i in tabBars[navIndex].son">
					{{data.cat_name}}
				</view>
			</view>
			<view class="content" v-if="navIndex==1">
				<view class="navindexzero" v-for="data,i in tabBars[navIndex].son">
					222
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	// import zero from "@/pages/classify/zaro.vue";
	// import two from "@/pages/classify/two.vue";
	import {
		goodscategory
	} from "../../utils/ajax.js"
	export default {
		data() {
			return {
				navIndex: 0,
				tabBars: []
			}
		},
		onLoad() {
			goodscategory({
				shop_id: 1
			}).then(res => {
				console.log(res.data.data[0].son);
				this.tabBars = res.data.data
			})
		},
		methods: {
			enter() {
				uni.navigateTo({
					url: "/pages/searchshop/searchshop"
				});
			},
			checkIndex(index) {
				console.log(index)
				this.navIndex = index;
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},

		}
	}
</script>

<style>
	.top {
		width: 100%;
		height: 150rpx;
		background-color: white;
		margin-top: 50rpx;
		padding: 30rpx 10rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #f5f5f5;
	}

	.scr {
		width: 700rpx;
		height: 80rpx;
		background-color: white;
		margin: 0 auto;
		border-radius: 50rpx;
		box-sizing: border-box;
		padding: 25rpx;
		color: #8a8a8a;
		background-color: #f5f5f5;
		font-size: 20rpx
	}

	.imagesrc {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		right: 50rpx;
	}


	.activite {
		color: #04c9c3;
	}

	.content {
		width: 700rpx;
		margin: 0 auto;
		background: #f5f5f5;
		display: flex;
		justify-content: space-between;
		/* height: 300px; */
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
		color: pink;
	}

	.scroll-view-item_H {
		display: inline-block;
		width: 20%;
		height: 50rpx;
		line-height: 50rpx;
		text-align: center;
		padding: 10px 0;
	}
	.navindexzero{
		width: 340rpx;
		height: 320rpx;
		background-color: pink;
	}
</style>
